package com.example.alltestapplication

import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.alltestapplication.ui.theme.AllTestApplicationTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            AllTestApplicationTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    MainScreen(modifier = Modifier.padding(innerPadding))
                }
            }
        }
    }

    @Composable
    fun MainScreen(modifier: Modifier = Modifier) {
        Column(modifier = modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally) {
            Button(onClick = { openWifiSettingsActivity() }) {
                Text(text = "Go to WiFi Settings")
            }
            
            Spacer(modifier = Modifier.height(16.dp))
            
            Button(onClick = { openAudioTrackTestActivity() }) {
                Text(text = "Go to AudioTrack Test")
            }
            
            Spacer(modifier = Modifier.height(16.dp))
            
            Button(onClick = { openVoiceCallActivity() }) {
                Text(text = "局域网语音通话")
            }
        }
    }

    private fun openWifiSettingsActivity() {
        val intent = Intent(this, WifiSettingsActivity::class.java)
        startActivity(intent)
    }
    
    private fun openAudioTrackTestActivity() {
        val intent = Intent(this, AudioTrackTestActivity::class.java)
        startActivity(intent)
    }
    
    private fun openVoiceCallActivity() {
        val intent = Intent(this, VoiceCallActivity::class.java)
        startActivity(intent)
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    AllTestApplicationTheme {
        Greeting("Android")
    }
}

